#include<iostream>
#include<vector>
#include<queue>
#include<cstring>
#include<cmath>
#include<map>
#include<set>
#include<cstdio>
#include<algorithm>
#define debug(a) cout<<#a<<"="<<a<<endl;
using namespace std;
const int maxn=1e5+100;
typedef long long LL;
inline LL read(){LL x=0,f=1;char ch=getchar();	while (!isdigit(ch)){if (ch=='-') f=-1;ch=getchar();}while (isdigit(ch)){x=x*10+ch-48;ch=getchar();}
return x*f;}
map<LL,LL>map1;
LL a[maxn];
bool vis[maxn];
int main(void)
{
  cin.tie(0);std::ios::sync_with_stdio(false);
  LL t;cin>>t;
  while(t--){
    LL n,m;cin>>n>>m;
    for(LL i=0;i<=m+10;i++) vis[i]=0;
    map1.clear();
    for(LL i=1;i<=n;i++){
        cin>>a[i];
        a[i]%=m;
        map1[a[i]]++;
    }
    LL ans=0;
    for(LL i=0;i<=m;i++){
        if(!vis[i]&&!vis[m-i]&&map1.count(i)&&map1.count(m-i)){
            if(abs(map1[i]-map1[m-i])<=1){
                ans++;
            }
            else{
                LL minv=min(map1[i],map1[m-i]);
                ans++;
                ans+=( (map1[i]+map1[m-i])-(minv*2+1));
            }
            vis[i]=vis[m-i]=1;
        }
        else if(!vis[i]&&map1.count(i)&&i!=0){
            ans+=map1[i];
            vis[i]=1;
        }
        else if(!vis[i]&&map1.count(i)&&i==0){
            ans++;
            vis[i]=1;
        }
    }
    cout<<ans<<"\n";
  }
return 0;
}
